luci-lua-runtime: render cbi header/footer templates via ucode runtime
authorJo-Philipp Wich <[email protected]>
Wed, 26 Oct 2022 19:59:08 +0000 (21:59 +0200)
committerJo-Philipp Wich <[email protected]>
Wed, 26 Oct 2022 20:02:16 +0000 (22:02 +0200)
Trigger rendering of CBI header and footer templates via the ucode runtime
`include()` in order to ensure that scope data is properly inherited from
Lua templates (`cbi/header`) including ucode templates (`header`).

This fixes automatic triggering of the config apply flow on legacy Lua CBI
forms.

Ref: https://github.com/openwrt/luci/pull/6056#issuecomment-1292396588
Signed-off-by: Jo-Philipp Wich <[email protected]>
modules/luci-lua-runtime/luasrc/dispatcher.lua

index e009147f0521a1b26f9b72371c238cd0e5cd1e0e..cd850aa3657ca2c4da996fe84ed51185741e5b0d 100644 (file)
@@ -267,7 +267,7 @@ function invoke_cbi_action(model, config, ...)
        http:header("X-CBI-State", state or 0)
 
        if not config.noheader then
-               tpl.render("cbi/header", {state = state})
+               _G.L.include("cbi/header", {state = state})
        end
 
        local redirect
@@ -318,7 +318,7 @@ function invoke_cbi_action(model, config, ...)
        end
 
        if not config.nofooter then
-               tpl.render("cbi/footer", {
+               _G.L.include("cbi/footer", {
                        flow          = config,
                        pageaction    = pageaction,
                        redirect      = redirect,